<template>
  <div    @click="openPayment ">
    <div style="overflow: hidden"  >
      <div class="price">
        <span>需付款</span>
        <span class="unit">¥</span>
        <span>25.</span>
        <span class="unit">2</span>
      </div>
      <div class="origin-price">
        <span>总价</span>
        <span class="unit">¥</span>
        <span>25.</span>
        <span class="unit">2</span>
      </div>
    </div>
    <div>
      <span class="right-button submit-btn" @click="openPayment">立即付款</span>
      <span class="right-button " @click="editAdress">修改地址</span>
      <span class="right-button" @click.stop="cancleOrder">关闭</span>
    </div>
  </div>
</template>

<script>
import {orderCancel} from '../api/order'
import {Toast} from 'vant'

export default {
  name: 'PaymentFooter',
  props: {
    order: Object,
    onDataChange: Function
  },
  methods: {
    openPayment () {
      this.$router.push({name: 'payment', params: {orderId: this.order.id}})
    },
    editAdress () {
      console.log('-------editAdress---------')
    },
    cancleOrder () {
      orderCancel({orderId: this.order.id}).then(res => {
        Toast.success('取消订单成功')
        this.onDataChange(this.order.id, 102)
      })
    }
  }
}
</script>

<style scoped>
.origin-price {
  margin-right: 10px;
  float: right;
  color: #c5c5c5;
}

.origin-price span {
  padding: 0;
  margin: 0;
}

.price {
  overflow: hidden;
  float: right;
  font-weight: bold;
  color: black;
}

.unit {
  font-size: 12px;
}

.right-button {
  margin: 10px 5px;
  overflow: hidden;
  float: right;
  border: #c5c5c5 1px solid;
  border-radius: 20px;
  padding: 5px 10px;
  font-size: 12px;
}
.submit-btn{
  border: #E65D6E 1px solid;
  color: #E65D6E;
}
</style>
